package br.com.marciotoshio.wave;

import java.util.HashMap;
import java.util.Random;

public class Languages {
	private static HashMap<EnumLanguage, String> _langs = new HashMap<EnumLanguage, String>();
	
	public Languages()
	{
		_langs.put(EnumLanguage.Afrikaans, "af");
		_langs.put(EnumLanguage.Albanian, "sq");
		_langs.put(EnumLanguage.Arabic, "ar");
		_langs.put(EnumLanguage.Belarusian, "be");
		_langs.put(EnumLanguage.Bulgarian, "bg");
		_langs.put(EnumLanguage.Catalan, "ca");
		_langs.put(EnumLanguage.Chinese, "CN");
		_langs.put(EnumLanguage.Croatian, "hr");
		_langs.put(EnumLanguage.Czech, "cs");
		_langs.put(EnumLanguage.Danish, "da");
		_langs.put(EnumLanguage.Dutch, "nl");
		_langs.put(EnumLanguage.English, "en");
		_langs.put(EnumLanguage.Estonian, "et");
		_langs.put(EnumLanguage.Filipino, "tl");
		_langs.put(EnumLanguage.Finnish, "fi");
		_langs.put(EnumLanguage.French, "fr");
		_langs.put(EnumLanguage.Galician, "gl");
		_langs.put(EnumLanguage.German, "de");
		_langs.put(EnumLanguage.Greek, "el");
		_langs.put(EnumLanguage.Hebrew, "iw");
		_langs.put(EnumLanguage.Hindi, "hi");
		_langs.put(EnumLanguage.Hungarian, "hu");
		_langs.put(EnumLanguage.Icelandic, "is");
		_langs.put(EnumLanguage.Indonesian, "id");
		_langs.put(EnumLanguage.Irish, "ga");
		_langs.put(EnumLanguage.Italian, "it");
		_langs.put(EnumLanguage.Japanese, "ja");
		_langs.put(EnumLanguage.Korean, "ko");
		_langs.put(EnumLanguage.Latvian, "lv");
		_langs.put(EnumLanguage.Lithuanian, "lt");
		_langs.put(EnumLanguage.Macedonian, "mk");
		_langs.put(EnumLanguage.Malay, "ms");
		_langs.put(EnumLanguage.Maltese, "mt");
		_langs.put(EnumLanguage.Norwegian, "no");
		_langs.put(EnumLanguage.Persian, "fa");
		_langs.put(EnumLanguage.Polish, "pl");
		_langs.put(EnumLanguage.Portuguese, "pt");
		_langs.put(EnumLanguage.Romanian, "ro");
		_langs.put(EnumLanguage.Russian, "ru");
		_langs.put(EnumLanguage.Serbian, "sr");
		_langs.put(EnumLanguage.Slovak, "sk");
		_langs.put(EnumLanguage.Slovenian, "sl");
		_langs.put(EnumLanguage.Spanish, "es");
		_langs.put(EnumLanguage.Swahili, "sw");
		_langs.put(EnumLanguage.Swedish, "sv");
		_langs.put(EnumLanguage.Thai, "th");
		_langs.put(EnumLanguage.Turkish, "tr");
		_langs.put(EnumLanguage.Ukrainian, "uk");
		_langs.put(EnumLanguage.Vietnamese, "vi");
		_langs.put(EnumLanguage.Welsh, "cy");
		_langs.put(EnumLanguage.Yiddish, "yi");
	}
	
	public HashMap<EnumLanguage, String> GetLanguages()
	{
		return _langs;
	}
	
	public String GetLanguage(EnumLanguage enumLang)
	{
		return _langs.get(enumLang);
	}
	
	public String GetLanguage(String lang)
	{
		return _langs.get(StringToEnumLanguage(lang));
	}
	
	public String GetRandomLanguage()
	{
		Random generator = new Random();
		Object[] values = _langs.values().toArray();
		String randomValue = (String)values[generator.nextInt(values.length)];
		return randomValue;
	}
	
	public Boolean IsLanguageValid(String lang)
	{
		return _langs.containsKey(StringToEnumLanguage(lang));
	}
	
	private EnumLanguage StringToEnumLanguage(String lang)
	{
		return EnumLanguage.valueOf(lang);
	}
	
	public enum EnumLanguage
	{
		Afrikaans,
		Albanian,
		Arabic,
		Belarusian,
		Bulgarian,
		Catalan,
		Chinese,
		Croatian,
		Czech,
		Danish,
		Dutch,
		English,
		Estonian,
		Filipino,
		Finnish,
		French,
		Galician,
		German,
		Greek,
		Hebrew,
		Hindi,
		Hungarian,
		Icelandic,
		Indonesian,
		Irish,
		Italian,
		Japanese,
		Korean,
		Latvian,
		Lithuanian,
		Macedonian,
		Malay,
		Maltese,
		Norwegian,
		Persian,
		Polish,
		Portuguese,
		Romanian,
		Russian,
		Serbian,
		Slovak,
		Slovenian,
		Spanish,
		Swahili,
		Swedish,
		Thai,
		Turkish,
		Ukrainian,
		Vietnamese,
		Welsh,
		Yiddish
	}

}
